package com.brzjomo.secretiveworld.world.gen;

import com.brzjomo.secretiveworld.init.ModBiomeTypes;
import com.brzjomo.secretiveworld.init.ModEntityTypes;

import net.minecraft.entity.EntitySpawnPlacementRegistry;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.passive.fish.AbstractFishEntity;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.Heightmap;

public class ModEntityGen {

	//注册生物生成方式
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static void registerAbstractFishType(EntityType typeIn, EntitySpawnPlacementRegistry.PlacementType PlacetypeIn) {
		EntitySpawnPlacementRegistry.register(typeIn, PlacetypeIn, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AbstractFishEntity::func_223363_b);
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static void registerMonsterType(EntityType typeIn, EntitySpawnPlacementRegistry.PlacementType PlacetypeIn) {
		EntitySpawnPlacementRegistry.register(typeIn, PlacetypeIn, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::canMonsterSpawnInLight);
	}

	public static void registerPlacementTypes() {
		registerAbstractFishType(ModEntityTypes.SWORD_FISH_ENTITY.get(), EntitySpawnPlacementRegistry.PlacementType.IN_WATER);
	}
	
	//生物生成
	public static void registerEntitySpawn(EntityType<?> entity, int weight, int minGroupIn, int maxGroupIn, Biome... biomes) {
		for(Biome biome:biomes) {
			if(biome != null) {
				biome.getSpawns(entity.getClassification()).add(new Biome.SpawnListEntry(entity, weight, minGroupIn, maxGroupIn));
			}
		}
	}
	
	public static void entitySpawn() {
		ModEntityGen.registerEntitySpawn(ModEntityTypes.SWORD_FISH_ENTITY.get(), 30, 5, 15, ModBiomeTypes.MERMAID_OCEAN.get());
	}
}
